package com.ctgu.rabbitmq.controller;

import com.ctgu.rabbitmq.service.QueueService;
import com.ctgu.rabbitmq.utils.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ ClassName QueueController
 * @ Author Alex2
 * @ Date 2025/8/15 9:11
 **/
@RestController
@RequestMapping("/api/queue")
public class QueueController {

    @Autowired
    private QueueService queueService;

    /**
     * @ Author: Alex
     * @ Description: 单条消息过期
     */
    // http://localhost:8080/api/queue/messageExpired
    @GetMapping("messageExpired")
    public ApiResult messageExpired() {
        return queueService.messageExpired();
    }

    /**
     * @ Author: Alex
     * @ Description: 队列过期
     */
    // http://localhost:8080/api/queue/queueExpired
    @GetMapping("queueExpired")
    public ApiResult queueExpired() throws InterruptedException {
        return queueService.queueExpired();
    }

    /**
     * @ Author: Alex
     * @ Description: 队列达到最大长度
     */
    // http://localhost:8080/api/queue/maxLength
    @GetMapping("maxLength")
    public ApiResult maxLength() {
        return queueService.maxLength();
    }

    /**
     * @ Author: Alex
     * @ Description: 消费者拒绝消费且不重新投递
     */
    // http://localhost:8080/api/queue/reject
    @GetMapping("reject")
    public ApiResult reject() {
        return queueService.reject();
    }
}
